﻿var h = null;
window.onload = function () {
    var ver = document.getElementById("version").value;
    var uri = document.getElementById("downloadUrl").value;

    new Clipboard('.copyAddress');
    h = window.innerHeight;
    console.log(h);
    setBodyHeight();
    //提示层点击事件
    document.getElementById('openTips').addEventListener('click', function () {
        this.style.display = "none";
    }, !1);
    //安装按钮点击事件
    var paltForm = getPlatform();
    if (paltForm === "WX") {
        document.getElementById('openTips').style.display = "block";
    }
    document.getElementById('downBtn').addEventListener('click', function () {
        if (paltForm === "WX") {
            document.getElementById('openTips').style.display = "block";
            return;
        } else if (paltForm === "ANDROID") {
            window.location.href = uri;
            return;
        } else if (paltForm === "IOS") {
            window.location.href = '';//'http://oz5a1hju1.bkt.clouddn.com/ydh-1.0.2.ipa';
        } else {
            window.location.href = uri;
        }
    }, !1)
    //下载高清二维码
    document.getElementById('downEwmBtn').addEventListener('click', function () {
        if (paltForm === "WX") {
            document.getElementById('openTips').style.display = "block";
        }
    }, !1)
    //复制下载地址
/*    document.getElementById('copyAddress').addEventListener('click', function () {
        alert('复制成功');
    }, !1)*/

};

//设置body最小高度
function setBodyHeight() {
    document.getElementsByTagName('body')[0].style.height = h + 'px';
}

//得到设备平台
function getPlatform() {
    var ua = window.navigator.userAgent.toLowerCase();//微信
    var u = navigator.userAgent;//手机类型android或ios
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {//微信
        return "WX";
    } else if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
        return "ANDROID";
    } else if (u.indexOf('iPhone') > -1) {//苹果手机
        return "IOS";
    } else {//其他
        return "WINDOWS";
    }
}
